let profile = null;

export function setProfile(_profile) {
  profile = _profile;
}

export function getProfile() {
  return profile;
}

export function clearProfile() {
  profile = null;
}

export function allowed(permission) {
  if (profile == null) {
    return false;
  }
  if (profile.admin) {
    return true;
  }
  return profile.permissions.some(p => p === permission);
}
